#include "stk_accept_encoding.h"
#include <string.h>

using namespace stk;

AcceptEncoding::AcceptEncoding()
{
    SetType(STK_FD_NAME_ACCEPT_ENCODING);

    m_value = "";
}

AcceptEncoding::AcceptEncoding(const AcceptEncoding &src)
{
    *this = src;
}

AcceptEncoding::AcceptEncoding(const char *buf)
{
    SetType(STK_FD_NAME_ACCEPT_ENCODING);
    parse(buf, strlen(buf));
}

AcceptEncoding::~AcceptEncoding()
{
    clear();
}

bool AcceptEncoding::isvalid() const
{
    return !m_value.empty();
}

void AcceptEncoding::clear()
{
    m_value = "";
}

int32_t AcceptEncoding::to_str(string &str)
{
    str += m_value;

    return 0;
}

int32_t AcceptEncoding::parse(const char *buf, int len)
{
    if (!buf)
    {
        printf("ERRO: <%010d> <%s.Parse> Invalid Buffer\n", GetSession(), GetTypeName());
        return -1;
    }

    clear();

    m_value = buf;
    return 0;
}

AcceptEncoding& AcceptEncoding::operator = (const AcceptEncoding &src)
{
    clear();

    m_value = src.m_value;
    MsgField::operator=(src);

    return *this;
}
